
package qaonair1;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class Consultants1 {
  private WebDriver driver;
  private String baseUrl;
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

  @Before
  public void setUp() throws Exception {
	  System.out.println("Hello this is @before every @Test");
    driver = new FirefoxDriver();
    baseUrl = "http://qaonair.com/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test
  public void testConsultants1() throws Exception {
	  System.out.println("Hello this is @test every @Test");
    driver.get(baseUrl + "/work-qa-onair/");
    driver.findElement(By.id("inf_field_FirstName")).clear();
    driver.findElement(By.id("inf_field_FirstName")).sendKeys("Qaoa1");
    driver.findElement(By.id("inf_field_LastName")).clear();
    driver.findElement(By.id("inf_field_LastName")).sendKeys("codex1");
    driver.findElement(By.id("inf_field_Email")).clear();
    driver.findElement(By.id("inf_field_Email")).sendKeys("Qaoa1.codex1@gmail.com");
    driver.findElement(By.id("inf_field_Phone1")).clear();
    driver.findElement(By.id("inf_field_Phone1")).sendKeys("1231231111");
    new Select(driver.findElement(By.id("inf_field_Country"))).selectByVisibleText("Angola");
    driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
  }

  @After
  public void tearDown() throws Exception {
	   System.out.println("Hello this is @after every @Test");
    driver.quit();
 
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {
      fail(verificationErrorString);
     
    }
  }

  private boolean isElementPresent(By by) {
    try {
      driver.findElement(by);
      return true;
    } catch (NoSuchElementException e) {
      return false;
    }
  }

  private boolean isAlertPresent() {
    try {
      driver.switchTo().alert();
      return true;
    } catch (NoAlertPresentException e) {
      return false;
    }
  }

  private String closeAlertAndGetItsText() {
    try {
      Alert alert = driver.switchTo().alert();
      String alertText = alert.getText();
      if (acceptNextAlert) {
        alert.accept();
      } else {
        alert.dismiss();
      }
      return alertText;
    } finally {
      acceptNextAlert = true;
    }
  }
}

